﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using System.Data;

namespace PeisongWeb
{
    public partial class productDetail : System.Web.UI.Page
    {
        protected int productid
        {
            get
            {
                int tmp;
                int.TryParse(Request.QueryString["product"],out tmp);
                return tmp;
            }
            set
            { productid = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (productid != 0)
            {
                getDetails();
                rptBind();
            }
            else
            {
                return;
            }
        }
        void getDetails()
        {
            ProductEntity _pro = logic.product.getById(productid);
            lbl_proNo.Text = _pro.ProductNo;
            lbl_proName.Text = _pro.Name;
            lbl_unit.Text = _pro.Unit;
            lbl_standard.Text = _pro.Standard;
            lbl_standardInfor.Text = _pro.StandardInfor;
            lbl_description.Text = _pro.Description;
        }
        void rptBind()
        {
            DataTable dt = logic.files.getListByProduct(productid);
            if (dt.Rows.Count > 0)
            {
                rpt_FilesList.DataSource = dt;
                rpt_FilesList.DataBind();
                img_product.Src = Library.Resource.UploadPath + Library.Resource.FileThumbnail1 + "/" + dt.Rows[0]["systemName"].ToString();
            }
            else
                img_product.Visible = false;
        }
    }
}
